//
//  MyLoveListViewController.m
//  CatMusic
//
//  Created by dllo on 15/5/2.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "MyLoveListViewController.h"
#import "BaseTableViewCell.h"
#import "BaseModel.h"
#import "MusicPlayViewController.h"
#import "NightMode.h"
@interface MyLoveListViewController ()
@property(nonatomic, retain)BaseTableViewCell *cell;
@property (nonatomic ,retain)UIImageView *backGrundImage;
@end

@implementation MyLoveListViewController
- (void)dealloc
{
    [_cell release];
    [super dealloc];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.arr = [NSMutableArray array];
        self.title = @"我喜欢";
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.backGrundImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [self.view addSubview:self.backGrundImage];
    self.backGrundImage.image = [UIImage imageNamed:@"nightCat"];
    [self.view sendSubviewToBack:self.backGrundImage];

    // Do any additional setup after loading the view.
    self.view.backgroundColor = [ UIColor whiteColor];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setLightDayModel) name:@"LightDayNSNotification" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setNightDayModel) name:@"NightDayNSNotification" object:nil];
    
    if ([NightMode shareNightMode].isNight) {
        [self setNightDayModel];
    } else {
        [self setLightDayModel];
    }

    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.arr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([NightMode shareNightMode].isNight) {
        [self setNightDayModel];
    } else {
        [self setLightDayModel];
    }

    self.cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    BaseModel *music = self.arr[indexPath.row];
    self.cell.backgroundColor = [UIColor clearColor];
    self.cell.BaseSongNameLabel.text = music.song_name;
    self.cell.BaseSingerNameLabel.text = music.singer_name;
    self.cell.baseNumberLabel.text = [NSString stringWithFormat:@"%ld" , (long)indexPath.row +1 ];
//    self.cell.BaseSongNameLabel.textColor = [UIColor whiteColor];
//    self.cell.BaseSingerNameLabel.textColor = [UIColor whiteColor];
//    self.cell.baseNumberLabel.textColor = [UIColor whiteColor];
    return self.cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    MusicPlayViewController *musicPlayVC = [[MusicPlayViewController alloc] init];
    musicPlayVC.modelArr = self.arr;
    musicPlayVC.indexPath = indexPath.row;
    [self.navigationController pushViewController:musicPlayVC animated:YES];
    [musicPlayVC release];
}


- (void)setLightDayModel
{

    self.view.backgroundColor = [UIColor whiteColor];
    self.tabBarController.tabBar.barTintColor = [UIColor colorWithRed:245 / 255.0 green:241/ 255.0 blue:143 / 255.0 alpha:1];//////
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:245 / 255.0 green:241/ 255.0 blue:143 / 255.0 alpha:1];//////
    
    UIColor * color = [UIColor blackColor];
    NSDictionary * dict = [NSDictionary dictionaryWithObject:color forKey:NSForegroundColorAttributeName];
    self.navigationController.navigationBar.titleTextAttributes = dict;
}

- (void)setNightDayModel
{

    self.view.backgroundColor = [UIColor colorWithRed:38 / 255.0 green:38/ 255.0 blue:38 / 255.0 alpha:1];
    self.tabBarController.tabBar.barTintColor = [UIColor blackColor];
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:38 / 255.0 green:38/ 255.0 blue:38 / 255.0 alpha:1];
    
    UIColor * color = [UIColor whiteColor];
    NSDictionary * dict = [NSDictionary dictionaryWithObject:color forKey:NSForegroundColorAttributeName];
    self.navigationController.navigationBar.titleTextAttributes = dict;
    
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
